﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ProjectMeeting.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The project meeting.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Models.Domain
{
    using System;
    using System.Collections.Generic;

    using NHibernate.Mapping.ByCode.Conformist;

    using ServiceLibrary.Models.Base;

    /// <summary>
    /// The project meeting.
    /// </summary>
    public class ProjectMeeting : Entity
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectMeeting"/> class.
        /// </summary>
        public ProjectMeeting()
        {
            this.Participants = new HashSet<Profile>();
            this.Groups = new HashSet<Group>();
            this.OwnerProjects = new HashSet<Project>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the date.
        /// </summary>
        public virtual DateTime? TimeOfActivity { get; set; }

        /// <summary>
        /// Gets or sets the groups.
        /// </summary>
        public virtual ICollection<Group> Groups { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether is national.
        /// </summary>
        public virtual bool IsNational { get; set; }

        /// <summary>
        /// Gets or sets the location.
        /// </summary>
        public virtual Location Location { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// Gets or sets the owner.
        /// </summary>
        public virtual Project Owner { get; set; }

        /// <summary>
        /// Gets or sets the owner projects.
        /// </summary>
        public virtual ICollection<Project> OwnerProjects { get; set; }

        /// <summary>
        /// Gets or sets the participants.
        /// </summary>
        public virtual ICollection<Profile> Participants { get; set; }

        /// <summary>
        /// Gets or sets the status.
        /// </summary>
        public virtual ProjectMeetingStatus Status { get; set; }

        #endregion
    }

    /// <summary>
    /// The project meeting mapping.
    /// </summary>
    public class ProjectMeetingMapping : ClassMapping<ProjectMeeting>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectMeetingMapping"/> class.
        /// </summary>
        public ProjectMeetingMapping()
        {
            this.Set(x => x.OwnerProjects, c => { }, m => m.ManyToMany());
            this.Property(x => x.Name);
            this.Property(x => x.IsNational);
            this.Property(x => x.TimeOfActivity);
            this.ManyToOne(x => x.Location);
            this.Set(x => x.Participants, c => { }, m => m.ManyToMany());
            this.ManyToOne(x => x.Status);
            this.Set(x => x.Groups, c => { }, m => m.ManyToMany());
        }

        #endregion
    }
}